package KMW;

import java.util.Scanner;

public class FindK {
        public static void main(String[] args){
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            int[] a = new int[n];
            int[] b = new int[n];
            int[] c = new int[n];
            //输入三个数组
            for(int i = 0; i < n; i++){
                a[i] = scanner.nextInt();
            }
            for(int i = 0; i < n; i++){
                b[i] = scanner.nextInt();
            }
            for(int i = 0; i < n; i++){
                c[i] = scanner.nextInt();
            }
            //找出第k大的数据
            int result = 0;
            //记录三个数组的下标
            int ai = 0;
            int bi = 0;
            int ci = 0;
            int[] newArray = new int[2 * n];
            int newIndex = 0;
            //拼接两个数组
            while (ai < a.length && bi < b.length){
                if(a[ai] <= b[bi]){
                    newArray[newIndex ++] = a[ai ++];
                }else {
                    newArray[newIndex ++] = b[bi ++];
                }
            }
            if(ai >= a.length){
                for (int i = bi; i < b.length ; i++) {
                    newArray[newIndex ++] = b[bi ++];
                }
            }else {
                for (int i = ai; i < a.length ; i++) {
                    newArray[newIndex ++] = a[ai ++];
                }
            }
            newIndex = 0;
            int count = 0;
            //开始比较
            while (newIndex < newArray.length && ci < c.length){
                if(newArray[newIndex] <= c[ci]){
                    result = newArray[newIndex++];
                }else {
                    result = c[ci++];
                }
                count++;
                if(count == k){
                    break;
                }
            }
            if(count == k){
                System.out.print(result);
            }else {
                if (newIndex >= newArray.length) {
                    for (int i = ci; i < c.length; i++) {
                        count++;
                        result = c[ci];
                        if (count == k) {
                            break;
                        }
                    }
                } else {
                    for (int i = newIndex; i < newArray.length; i++) {
                        count++;
                        result = newArray[newIndex];
                        if (count == k) {
                            break;
                        }
                    }
                }
                System.out.print(result);
            }
        }
    }
